package GUI;

import swimming.VIPcard;
import swimming.consumption;
import use.VIPuse;
import use.consumeuse;
import use.consumptionuse;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

public class VIP {
    private JPanel panel1;
    private JButton 确定Button;
    private JTextField textField1;
    private JComboBox comboBox1;
    private JTextField TextField;
    private JTextField textField2;
    private JComboBox comboBox2;
    private JButton 会员卡充值Button;
    private JButton 查询修改会员信息Button;
    private JButton 更改系统密码Button;
    private JButton 新会员注册Button;
    private JButton 查询消费记录Button;
    private JButton 会员卡汇总记录Button;
    private JButton 使用会员卡Button;
    private JButton 消费记录报表Button;

    public static void iface(){
        JFrame frame = new JFrame("游泳馆会员管理系统");
        frame.setSize(500, 400);
        frame.setLocation(400, 200);

        VIP t1 = new VIP();
        frame.add(t1.panel1);

        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public VIP()   {
        会员卡充值Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new recharge().iface();
            }
        });
        查询消费记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new consume().iface();
            }
        });
        查询修改会员信息Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new revise().iface();
            }
        });
        更改系统密码Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new password().iface();
            }
        });
        新会员注册Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new VIP().iface();
            }
        });
        会员卡汇总记录Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new totalVIP().iface();
            }
        });
        使用会员卡Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new usecard().iface();
            }
        });
        确定Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                VIPuse vip = new VIPuse();
                consumptionuse c=new consumptionuse();
                consumeuse co=new consumeuse();
                String[] a = new String[6];
                String[] b = new String[4];
                String[] d = new String[3];
                Calendar calendar = Calendar.getInstance();
                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                b[0]=textField2.getText();
                b[1]=textField2.getText();
                b[2]=formatter.format(calendar.getTime());
                b[3]=TextField.getText();
                a[0] = TextField.getText();
                a[1] = textField1.getText();
                a[2] = comboBox2.getSelectedItem().toString();
                a[3] = comboBox1.getSelectedItem().toString();
                a[4] = textField2.getText();
                a[5] = null;
                d[0]=TextField.getText();
                d[1]=b[2];
                d[2]="0";
                List<VIPcard> state = (List<VIPcard>) vip.增加(a);
                if(state == null)
                {
                    JOptionPane.showMessageDialog(null, "非营业时间", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }
                else {
                    if(comboBox1.getSelectedItem().toString().equals("储值卡"))
                    {
                       c.会员卡充值(b);
                       co.增加(d);
                    }
                    else{
                        b[0]="0";
                        b[1]="0";
                        b[2]=formatter.format(calendar.getTime());
                        b[3]=TextField.getText();
                        c.会员卡充值(b);
                        co.增加(d);
                    }
                    JOptionPane.showMessageDialog(null, "注册成功", "提示",
                            JOptionPane.INFORMATION_MESSAGE);
                }

            }
        });
        消费记录报表Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new baobiao().iface();
            }
        });
    }

    public static void main(String[] args) {
       iface();
    }

}
